/**
 * bool type to chinese bool type
 * @param value bool type
 * @returns true=是,false=否
 */
const boolToStr = (value: boolean): string => {
    if (value) return '是'
    return '否'
}

/**
 * long type name to short,split it and get last
 * @param value long type name
 * @returns short type name
 */
const longTypeNameToShort = (value: string) => {
    if (value != null) {
        const data = value.split('.')
        return data[data.length - 1]
    }
    return value
}

const upperFirst = (value: string) => {
    return value.charAt(0).toUpperCase() + value.slice(1)
}

const lowerFirst = (value: string) => {
    return value.charAt(0).toLowerCase() + value.slice(1)
}

const formatFileName = (fileName: string): string => {
    const names = fileName.split('/')
    let result = ''
    for (let i = 0, len = names.length; i < len; i++) {
        result = result + upperFirst(names[i].trim())
    }
    return result.trim()
}

export { boolToStr, longTypeNameToShort, upperFirst, lowerFirst, formatFileName }
